﻿<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:settings="clr-namespace:Video_Controller"
    Title="Video Controller V1.0.0" Width="600" SizeToContent="Height" ResizeMode="NoResize"
        Background="{DynamicResource WindowBackgroundBrush}">
    <Window.Resources>
        <DataTemplate x:Key="presettItemTemplate">
                    <TextBlock Text="{Binding XPath=@name}" FontSize="12" Height="20"/>
        </DataTemplate>

        <Style x:Key="{x:Type ContextMenu}" TargetType="{x:Type ContextMenu}">
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ContextMenu}">
                        <Border Background="{DynamicResource WindowBackgroundBrush}" CornerRadius="4, 4, 4, 4" BorderBrush="DarkGray" BorderThickness="2" Opacity="0.96">
                            <StackPanel ClipToBounds="True" Orientation="Vertical" IsItemsHost="True" Margin="5,4,5,4"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <ControlTemplate x:Key="{x:Static MenuItem.TopLevelItemTemplateKey}" TargetType="{x:Type MenuItem}">
            <Border Name="Border" >
                <Grid>
                    <ContentPresenter Margin="6,3,6,3" ContentSource="Header" RecognizesAccessKey="True" />
                </Grid>
            </Border>
        </ControlTemplate>
    </Window.Resources>
    <Window.ContextMenu>
        <ContextMenu>
            <MenuItem Name="AppSettings" Header="Application Settings" Click="AppSettings_Click">
            </MenuItem>
        </ContextMenu>
    </Window.ContextMenu>
    <Grid>
        <Grid.Resources>
            <Style TargetType="{x:Type Button}" 
                          BasedOn="{StaticResource {x:Type Button}}">
                <Setter Property="Margin" Value="4,4,4,4" />
            </Style>
            <Style TargetType="{x:Type ComboBox}" 
                          BasedOn="{StaticResource {x:Type ComboBox}}">
                <Setter Property="Margin" Value="4,4,4,4" />
            </Style>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="35" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.DataContext>
            <XmlDataProvider  x:Name="xmlData" 
             XPath="presets/preset" IsAsynchronous="False" />
        </Grid.DataContext>
        <Label VerticalAlignment="Bottom" Content="Select Video Scheme:" />
        <Label Grid.Column="1" Name="lblCurrentVideoScheme" Content="Current Scheme: not available" />
        <ComboBox Name="cmbPresets" Grid.Row="1"  ItemsSource="{Binding}"
                  SelectedValuePath="@name"
                  ItemTemplate="{StaticResource presettItemTemplate}"
                     IsSynchronizedWithCurrentItem="True" SelectedIndex="-1"
 SelectionChanged="cmbPresets_SelectionChanged">
         </ComboBox>
        <Button Name="btnDeletePreset" Grid.Row="1" Grid.Column="1" Width="100" HorizontalAlignment="Right" Click="btnDeletePreset_Click">Delete Preset</Button>
        <Button Name="btnSendToTVs" Grid.Row="1" Grid.Column="1" Width="100" HorizontalAlignment="Left" Click="btnSendToTVs_Click">Send to TV's</Button>
        <Border  Grid.ColumnSpan="2" Grid.Row="2" BorderBrush="Black" BorderThickness="0.5" Margin="4" CornerRadius="5" >
        <Expander Name="InputExpander" Header="Input Status">
            <Grid Name="gridManualControls" IsEnabled="False">
                    <Grid.Resources>
                        <Style TargetType="{x:Type Label}" 
                          BasedOn="{StaticResource {x:Type Label}}">
                        <Setter Property="HorizontalAlignment" Value="Right"/>
                        <Setter Property="VerticalAlignment" Value="Center"/>
                        </Style>
                    </Grid.Resources>
                    <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="35"  />
                    <RowDefinition Height="35"  />
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                </Grid.RowDefinitions>
                <Label Grid.Row="0" Grid.Column="0" Content="{Binding Source={x:Static settings:MySettings.Default},Path=Output1, Mode=TwoWay}"/>
                <Label Grid.Row="1" Grid.Column="0" Content="{Binding Source={x:Static settings:MySettings.Default},Path=Output2, Mode=TwoWay}"/>
                <Label Grid.Row="2" Grid.Column="0" Content="{Binding Source={x:Static settings:MySettings.Default},Path=Output3, Mode=TwoWay}"/>
                <Label Grid.Row="3" Grid.Column="0" Content="{Binding Source={x:Static settings:MySettings.Default},Path=Output4, Mode=TwoWay}"/>
                <Label Grid.Row="0" Grid.Column="2" Content="{Binding Source={x:Static settings:MySettings.Default},Path=Output5, Mode=TwoWay}"/>
                <Label Grid.Row="1" Grid.Column="2" Content="{Binding Source={x:Static settings:MySettings.Default},Path=Output6, Mode=TwoWay}"/>
                <Label Grid.Row="2" Grid.Column="2" Content="{Binding Source={x:Static settings:MySettings.Default},Path=Output7, Mode=TwoWay}"/>
                <Label Grid.Row="3" Grid.Column="2" Content="{Binding Source={x:Static settings:MySettings.Default},Path=Output8, Mode=TwoWay}"/>
                
                <ComboBox Name="cmbInput1" Grid.Row="0" Grid.Column="1" SelectedIndex="{Binding XPath=output1}" IsSynchronizedWithCurrentItem="True">
                    <ComboBoxItem Content="Blank" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input1, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input2, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input3, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input4, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input5, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input6, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input7, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input8, Mode=TwoWay}" />
                </ComboBox>
                <ComboBox  Name="cmbInput2" Grid.Row="1" Grid.Column="1" SelectedIndex="{Binding XPath=output2}" IsSynchronizedWithCurrentItem="True">
                    <ComboBoxItem Content="Blank" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input1, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input2, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input3, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input4, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input5, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input6, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input7, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input8, Mode=TwoWay}" />
                </ComboBox>
                <ComboBox  Name="cmbInput3" Grid.Row="2" Grid.Column="1" SelectedIndex="{Binding XPath=output3}" IsSynchronizedWithCurrentItem="True">
                    <ComboBoxItem Content="Blank" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input1, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input2, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input3, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input4, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input5, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input6, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input7, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input8, Mode=TwoWay}" />
                </ComboBox>
                <ComboBox  Name="cmbInput4" Grid.Row="3" Grid.Column="1" SelectedIndex="{Binding XPath=output4}" IsSynchronizedWithCurrentItem="True">
                    <ComboBoxItem Content="Blank" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input1, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input2, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input3, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input4, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input5, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input6, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input7, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input8, Mode=TwoWay}" />
                </ComboBox>
                <ComboBox  Name="cmbInput5" Grid.Row="0" Grid.Column="3" SelectedIndex="{Binding XPath=output5}" IsSynchronizedWithCurrentItem="True">
                    <ComboBoxItem Content="Blank" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input1, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input2, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input3, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input4, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input5, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input6, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input7, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input8, Mode=TwoWay}" />
                </ComboBox>
                <ComboBox  Name="cmbInput6" Grid.Row="1" Grid.Column="3" SelectedIndex="{Binding XPath=output6}" IsSynchronizedWithCurrentItem="True">
                    <ComboBoxItem Content="Blank" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input1, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input2, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input3, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input4, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input5, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input6, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input7, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input8, Mode=TwoWay}" />
                </ComboBox>
                <ComboBox  Name="cmbInput7" Grid.Row="2" Grid.Column="3" SelectedIndex="{Binding XPath=output7}" IsSynchronizedWithCurrentItem="True">
                    <ComboBoxItem Content="Blank" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input1, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input2, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input3, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input4, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input5, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input6, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input7, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input8, Mode=TwoWay}" />
                </ComboBox>
                <ComboBox  Name="cmbInput8" Grid.Row="3" Grid.Column="3" SelectedIndex="{Binding XPath=output8}" IsSynchronizedWithCurrentItem="True">
                    <ComboBoxItem Content="Blank" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input1, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input2, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input3, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input4, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input5, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input6, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input7, Mode=TwoWay}" />
                    <ComboBoxItem Content="{Binding Source={x:Static settings:MySettings.Default},Path=Input8, Mode=TwoWay}" />
                </ComboBox>
                <Button Name="btnSendToTVs2" Grid.Row="4" Grid.Column="2" Width="100" Click="btnSendToTVs_Click" HorizontalAlignment="Left">Send to TV's</Button>
                <Button Name="btnSavePreset" Grid.Row="4" Grid.Column="3" Width="100" Click="btnSavePreset_Click" HorizontalAlignment="Right">Save as preset</Button>
                </Grid>
        </Expander>
            </Border>
    </Grid>
</Window>
